<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
<TITLE>terminal_interface-curses-terminfo.adb</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
*.comment {
	color: green;
}
*.symbol {
	color: red;
}
</style>
</HEAD>
<BODY>
<HR><DIV style="text-align:center"><H1> File : terminal_interface-curses-terminfo.adb </H1></DIV><HR>
<PRE>
<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>--                           <A HREF="http://www.gnat.com">GNAT</A> ncurses Binding                           --</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>--                    Terminal_Interface.Curses.Terminfo                    --</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>--                                 B O D Y                                  --</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
<span class="comment"><EM>-- Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.              --</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>-- Permission is hereby granted, free of charge, to any person obtaining a  --</EM></span>
<span class="comment"><EM>-- copy of this software and associated documentation files (the            --</EM></span>
<span class="comment"><EM>-- "Software"), to deal in the Software without restriction, including      --</EM></span>
<span class="comment"><EM>-- without limitation the rights to use, copy, modify, merge, publish,      --</EM></span>
<span class="comment"><EM>-- distribute, distribute with modifications, sublicense, and/or sell       --</EM></span>
<span class="comment"><EM>-- copies of the Software, and to permit persons to whom the Software is    --</EM></span>
<span class="comment"><EM>-- furnished to do so, subject to the following conditions:                 --</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>-- The above copyright notice and this permission notice shall be included  --</EM></span>
<span class="comment"><EM>-- in all copies or substantial portions of the Software.                   --</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --</EM></span>
<span class="comment"><EM>-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --</EM></span>
<span class="comment"><EM>-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --</EM></span>
<span class="comment"><EM>-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --</EM></span>
<span class="comment"><EM>-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --</EM></span>
<span class="comment"><EM>-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --</EM></span>
<span class="comment"><EM>-- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --</EM></span>
<span class="comment"><EM>--                                                                          --</EM></span>
<span class="comment"><EM>-- Except as contained in this notice, the name(s) of the above copyright   --</EM></span>
<span class="comment"><EM>-- holders shall not be used in advertising or otherwise to promote the     --</EM></span>
<span class="comment"><EM>-- sale, use or other dealings in this Software without prior written       --</EM></span>
<span class="comment"><EM>-- authorization.                                                           --</EM></span>
<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
<span class="comment"><EM>--  Author:  Juergen Pfeifer, 1996</EM></span>
<span class="comment"><EM>--  Version Control:</EM></span>
<span class="comment"><EM>--  @Revision: 1.6 @</EM></span>
<span class="comment"><EM>--  @Date: 2009/12/26 17:38:58 @</EM></span>
<span class="comment"><EM>--  Binding Version 01.00</EM></span>
<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>

<b>with</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#ref_45_35">Aux</A>; <b>use</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#ref_45_35">Aux</A>;
<b>with</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C; <b>use</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C;
<b>with</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C.Strings; <b>use</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C.Strings;
<b>with</b> Ada.Unchecked_Conversion;

<b>package</b> <b>body</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<span class="symbol"><A NAME="ref_48_40" HREF="terminal_interface-curses-terminfo__ads.htm#ref_44_35">Terminfo</A></span> <b>is</b>

   <b>function</b> <span class="symbol"><A NAME="ref_50_13" HREF="terminal_interface-curses-terminfo__adb.htm#ref_52_13">Is_MinusOne_Pointer</A></span> (<span class="symbol"><A NAME="ref_50_34" HREF="terminal_interface-curses-terminfo__adb.htm#ref_52_34">P</A></span> : chars_ptr) <b>return</b> Boolean;

   <b>function</b> <span class="symbol"><A NAME="ref_52_13" HREF="terminal_interface-curses-terminfo__adb.htm#ref_50_13">Is_MinusOne_Pointer</A></span> (<span class="symbol"><A NAME="ref_52_34" HREF="terminal_interface-curses-terminfo__adb.htm#ref_50_34">P</A></span> : chars_ptr) <b>return</b> Boolean <b>is</b>
      <b>type</b> <span class="symbol"><A NAME="ref_53_12">Weird_Address</A></span> <b>is</b> <b>new</b> System.Storage_Elements.Integer_Address;
      <span class="symbol"><A NAME="ref_54_7">Invalid_Pointer</A></span> : <b>constant</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_53_12">Weird_Address</A> := -1;
      <b>function</b> To_Weird <b>is</b> <b>new</b> Ada.Unchecked_Conversion
        (Source =&gt; chars_ptr, Target =&gt; <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_53_12">Weird_Address</A>);
   <b>begin</b>
      <b>if</b> To_Weird (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_50_34">P</A>) = <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_54_7">Invalid_Pointer</A> <b>then</b>
         <b>return</b> True;
      <b>else</b>
         <b>return</b> False;
      <b>end</b> <b>if</b>;
   <b>end</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_50_13">Is_MinusOne_Pointer</A>;
   <b>pragma</b> Inline (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_50_13">Is_MinusOne_Pointer</A>);

<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
   <b>function</b> <span class="symbol"><A NAME="ref_67_13" HREF="terminal_interface-curses-terminfo__ads.htm#ref_64_13">Get_Flag</A></span> (<span class="symbol"><A NAME="ref_67_23" HREF="terminal_interface-curses-terminfo__ads.htm#ref_64_23">Name</A></span> : String) <b>return</b> Boolean
   <b>is</b>
      <b>function</b> <span class="symbol"><A NAME="ref_69_16">tigetflag</A></span> (<span class="symbol"><A NAME="ref_69_27" HREF="terminal_interface-curses-terminfo__adb.htm#ref_69_16">id</A></span> : char_array) <b>return</b> <A HREF="terminal_interface-curses__ads.htm#ref_2098_9">Curses_Bool</A>;
      <b>pragma</b> Import (C, tigetflag);
      <span class="symbol"><A NAME="ref_71_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_64_23">Name</A>'Length);
      <span class="symbol"><A NAME="ref_72_7">Length</A></span> : size_t;
   <b>begin</b>
      To_C (<A HREF="terminal_interface-curses-terminfo__ads.htm#ref_64_23">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_71_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_72_7">Length</A>);
      <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_69_16">tigetflag</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_71_7">Txt</A>) = <A HREF="terminal_interface-curses__ads.htm#ref_2098_9">Curses_Bool</A> (<A HREF="terminal_interface-curses-aux__ads.htm#ref_67_4">Curses_True</A>) <b>then</b>
         <b>return</b> True;
      <b>else</b>
         <b>return</b> False;
      <b>end</b> <b>if</b>;
   <b>end</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_64_13">Get_Flag</A>;

<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
   <b>procedure</b> <span class="symbol"><A NAME="ref_83_14" HREF="terminal_interface-curses-terminfo__ads.htm#ref_57_14">Get_String</A></span> (<span class="symbol"><A NAME="ref_83_26" HREF="terminal_interface-curses-terminfo__ads.htm#ref_57_26">Name</A></span>   : String;
                         <span class="symbol"><A NAME="ref_84_26" HREF="terminal_interface-curses-terminfo__ads.htm#ref_58_26">Value</A></span>  : <b>out</b> Terminfo_String;
                         <span class="symbol"><A NAME="ref_85_26" HREF="terminal_interface-curses-terminfo__ads.htm#ref_59_26">Result</A></span> : <b>out</b> Boolean)
   <b>is</b>
      <b>function</b> <span class="symbol"><A NAME="ref_87_16">tigetstr</A></span> (<span class="symbol"><A NAME="ref_87_26" HREF="terminal_interface-curses-terminfo__adb.htm#ref_87_16">id</A></span> : char_array) <b>return</b> chars_ptr;
      <b>pragma</b> Import (C, tigetstr, "tigetstr");
      <span class="symbol"><A NAME="ref_89_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_57_26">Name</A>'Length);
      <span class="symbol"><A NAME="ref_90_7">Length</A></span> : size_t;
      <span class="symbol"><A NAME="ref_91_7">Txt2</A></span> : chars_ptr;
   <b>begin</b>
      To_C (<A HREF="terminal_interface-curses-terminfo__ads.htm#ref_57_26">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_89_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_90_7">Length</A>);
      <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_91_7">Txt2</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_87_16">tigetstr</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_89_7">Txt</A>);
      <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_91_7">Txt2</A> = Null_Ptr <b>then</b>
         <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_59_26">Result</A> := False;
      <b>elsif</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_50_13">Is_MinusOne_Pointer</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_91_7">Txt2</A>) <b>then</b>
         <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#ref_521_4">Curses_Exception</A>;
      <b>else</b>
         <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_58_26">Value</A>  := Terminfo_String (<A HREF="terminal_interface-curses-aux__ads.htm#ref_97_13">Fill_String</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_91_7">Txt2</A>));
         <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_59_26">Result</A> := True;
      <b>end</b> <b>if</b>;
   <b>end</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_57_14">Get_String</A>;

<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
   <b>function</b> <span class="symbol"><A NAME="ref_106_13" HREF="terminal_interface-curses-terminfo__ads.htm#ref_60_13">Has_String</A></span> (<span class="symbol"><A NAME="ref_106_25" HREF="terminal_interface-curses-terminfo__ads.htm#ref_60_25">Name</A></span> : String) <b>return</b> Boolean
   <b>is</b>
      <b>function</b> <span class="symbol"><A NAME="ref_108_16">tigetstr</A></span> (<span class="symbol"><A NAME="ref_108_26" HREF="terminal_interface-curses-terminfo__adb.htm#ref_108_16">id</A></span> : char_array) <b>return</b> chars_ptr;
      <b>pragma</b> Import (C, tigetstr, "tigetstr");
      <span class="symbol"><A NAME="ref_110_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_60_25">Name</A>'Length);
      <span class="symbol"><A NAME="ref_111_7">Length</A></span> : size_t;
      <span class="symbol"><A NAME="ref_112_7">Txt2</A></span> : chars_ptr;
   <b>begin</b>
      To_C (<A HREF="terminal_interface-curses-terminfo__ads.htm#ref_60_25">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_110_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_111_7">Length</A>);
      <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_112_7">Txt2</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_108_16">tigetstr</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_110_7">Txt</A>);
      <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_112_7">Txt2</A> = Null_Ptr <b>then</b>
         <b>return</b> False;
      <b>elsif</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_50_13">Is_MinusOne_Pointer</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_112_7">Txt2</A>) <b>then</b>
         <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#ref_521_4">Curses_Exception</A>;
      <b>else</b>
         <b>return</b> True;
      <b>end</b> <b>if</b>;
   <b>end</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_60_13">Has_String</A>;

<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
   <b>function</b> <span class="symbol"><A NAME="ref_126_13" HREF="terminal_interface-curses-terminfo__ads.htm#ref_68_13">Get_Number</A></span> (<span class="symbol"><A NAME="ref_126_25" HREF="terminal_interface-curses-terminfo__ads.htm#ref_68_25">Name</A></span> : String) <b>return</b> Integer <b>is</b>
      <b>function</b> <span class="symbol"><A NAME="ref_127_16">tigetstr</A></span> (<span class="symbol"><A NAME="ref_127_26" HREF="terminal_interface-curses-terminfo__adb.htm#ref_127_16">s</A></span> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
      <b>pragma</b> Import (C, tigetstr);
      <span class="symbol"><A NAME="ref_129_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_68_25">Name</A>'Length);
      <span class="symbol"><A NAME="ref_130_7">Length</A></span> : size_t;
   <b>begin</b>
      To_C (<A HREF="terminal_interface-curses-terminfo__ads.htm#ref_68_25">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_129_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_130_7">Length</A>);
      <b>return</b> Integer (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_127_16">tigetstr</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_129_7">Txt</A>));
   <b>end</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_68_13">Get_Number</A>;

<span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
   <b>procedure</b> <span class="symbol"><A NAME="ref_137_14" HREF="terminal_interface-curses-terminfo__ads.htm#ref_76_14">Put_String</A></span> (<span class="symbol"><A NAME="ref_137_26" HREF="terminal_interface-curses-terminfo__ads.htm#ref_76_26">Str</A></span>    : Terminfo_String;
                         <span class="symbol"><A NAME="ref_138_26" HREF="terminal_interface-curses-terminfo__ads.htm#ref_77_26">affcnt</A></span> : Natural := 1;
                         <span class="symbol"><A NAME="ref_139_26" HREF="terminal_interface-curses-terminfo__ads.htm#ref_78_26">putc</A></span>   : <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_71_9">putctype</A> := <b>null</b>) <b>is</b>
      <b>function</b> <span class="symbol"><A NAME="ref_140_16">tputs</A></span> (<span class="symbol"><A NAME="ref_140_23" HREF="terminal_interface-curses-terminfo__adb.htm#ref_140_16">str</A></span>    : char_array;
                      <span class="symbol"><A NAME="ref_141_23" HREF="terminal_interface-curses-terminfo__adb.htm#ref_140_16">affcnt</A></span> : <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
                      <span class="symbol"><A NAME="ref_142_23" HREF="terminal_interface-curses-terminfo__adb.htm#ref_140_16">putc</A></span>   : <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_71_9">putctype</A>) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
      <b>function</b> <span class="symbol"><A NAME="ref_143_16">putp</A></span> (<span class="symbol"><A NAME="ref_143_22" HREF="terminal_interface-curses-terminfo__adb.htm#ref_143_16">str</A></span> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
      <b>pragma</b> Import (C, tputs);
      <b>pragma</b> Import (C, putp);
      <span class="symbol"><A NAME="ref_146_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_76_26">Str</A>'Length);
      <span class="symbol"><A NAME="ref_147_7">Length</A></span> : size_t;
      <span class="symbol"><A NAME="ref_148_7">Err</A></span> : <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
   <b>begin</b>
      To_C (String (<A HREF="terminal_interface-curses-terminfo__ads.htm#ref_76_26">Str</A>), <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_146_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_147_7">Length</A>);
      <b>if</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_78_26">putc</A> = <b>null</b> <b>then</b>
         <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_148_7">Err</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_143_16">putp</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_146_7">Txt</A>);
      <b>else</b>
         <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_148_7">Err</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_140_16">tputs</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#ref_146_7">Txt</A>, <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A> (<A HREF="terminal_interface-curses-terminfo__ads.htm#ref_77_26">affcnt</A>), <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_78_26">putc</A>);
      <b>end</b> <b>if</b>;
      <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#ref_148_7">Err</A> = <A HREF="terminal_interface-curses-aux__ads.htm#ref_65_4">Curses_Err</A> <b>then</b>
         <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#ref_521_4">Curses_Exception</A>;
      <b>end</b> <b>if</b>;
   <b>end</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#ref_76_14">Put_String</A>;

<b>end</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<A HREF="terminal_interface-curses-terminfo__ads.htm#ref_44_35">Terminfo</A>;
</PRE></BODY></HTML>
